﻿using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using System.Threading.Tasks;
using VisionCloud.Domain.Common;
using VisionCloud.Domain.DtoModel.Sys;
using VisionCloud.Domain.Filters;
using VisionCloud.Service.Sys;
using VisionCloud.Utility.Extensions;

namespace VisionCloud.Api.Controllers.Sys
{
    /// <summary>
    /// 发送邮件控制器
    /// </summary>
    [SystemModule("发送短信控制器")]
    [ApiAuthorize(PolicyEnum.RequireRolePermission)]
    [ApiVersion("1.0")]
    [Route("api/sys/[controller]/[Action]")]
    [ApiExplorerSettings(GroupName = "发送短信控制器")]
    public class SmsController : ApiBaseController
    {
        /// <summary>
        /// 短信服务
        /// </summary>
        public SmsService SmsService { get; set; }

        /// <summary>
        /// 发送短信
        /// </summary>
        /// <param name="smsDto"></param>
        /// <returns></returns>
        [HttpPost]
        [AllowAnonymous]
        public async Task<ApiResult> SendSms(SmsDto smsDto)
        {
            return await TryCatchAsync(SmsService.SendSms(HttpContext.GetClientUserIp(), smsDto.Phone, smsDto.Content));
        }
    }
}